/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
 * Description: 上机编程认证
 * Note: 缺省代码仅供参考，可自行决定使用、修改或删除
 */
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

class Solution {
public:
    // 待实现函数，在此函数中填入答题代码;
    string Calling(const string &status, const vector<pair<int, string> > &regCallForwardNums) {
        int typeId;
        if (status == "busy") {
            typeId = 1;
        } else if (status == "no-response") {
            typeId = 2;
        } else if (status == "unreachable") {
            typeId = 3;
        } else {
            typeId = 4;
        }
        string tmpNum = "nullptr";
        int tmpLevel = 5;
        for (const pair<int, string> &pair: regCallForwardNums) {
            //如果当前状态和用户状态相同，且当前呼叫优先级更低，则更新
            //如果当前并没有设置转移，且当前状态为默认转移则更新
            if (pair.first == 0) {
                tmpLevel = 0;
                tmpNum = pair.second;
            } else if (tmpLevel >= pair.first and (pair.first == typeId or pair.first == 4)) {
                tmpNum = pair.second;
                tmpLevel = pair.first;
            }
        }
        //强制转移，直接返回电话
        if (tmpLevel == 0) {
            return tmpNum;
        }
        //如果有转移且状态不是idle，则返回电话
        if (tmpLevel != 5 and typeId != 4) {
            return tmpNum;
        }
        //若用户状态为idle，且未发生强制转移时，则呼叫本机成功，输出success
        if (typeId == 4) {
            return "success";
        }
        return "failure";
    }
};

// 以下为考题输入输出框架，此部分代码不建议改动
inline string ReadLine() {
    string line;
    getline(cin, line);
    return line;
}

inline vector<string> ReadLines(int size) {
    vector<string> lines(size);
    for (int i = 0; i < size; ++i) {
        lines[i] = ReadLine();
    }
    return lines;
}

inline pair<string, string> SplitPair(const string &word, char delimeter) {
    auto pos = word.find(delimeter);
    return make_pair(word.substr(0, pos), word.substr(pos + 1));
}

int main() {
    pair<string, string> p = SplitPair(ReadLine(), ' ');
    int n = stoi(p.first);
    string status = p.second;
    vector<string> lines = ReadLines(n);
    vector<pair<int, string> > regCallForwardNums;
    for (auto s: lines) {
        p = SplitPair(s, ' ');
        regCallForwardNums.push_back(make_pair(stoi(p.first), p.second));
    }

    Solution solu;
    string out = solu.Calling(status, regCallForwardNums);
    cout << out << endl;
    return 0;
}
